/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mocks;

import com.google.gson.Gson;
import engine.City;
import engine.Country;
import engine.FullPersone;
import engine.GType;
import engine.Street;
import engine.TypeAdress;
import engine.TypePhone;
import protocol.Command;

/**
 *
 * @author Alexx
 */
class MockReaction {

    public MockReaction() {
    }

    void get(String str, OneThreadMock mysrv) {
        String type;

       
    //   log.info("Start Protocol");
       
//       catch (Exception e) {
//            log.fatal("Game exception", e);
//        }
       
      // log.debug("Protocol str" + str);
         Gson gson = new Gson();
         Command obj = gson.fromJson(str, Command.class);
         type = obj.Type;
         String data = obj.Data;
         String add = obj.Add;
       
       
       
       if (type.equals("Connect"))
       {
         mysrv.sendUser("{\"Type\":\"Connect\",\"Data\":\"Admin\",\"Add\":\"1\"}");
           
       }
       
       // GETER
       if (type.equals("Get"))
       {
         GType obj2 = gson.fromJson(data, GType.class);
        // log.debug(name);
         if (obj2.Type.equals("List"))
         {
           mysrv.sendUser("{\"Type\":\"Get\",\"Data\":\"{\\\"Type\\\":\\\"List\\\"}\",\"Add\":\"[{\\\"ID\\\":\\\"1\\\",\\\"FName\\\":\\\"Peta2\\\",\\\"LNmae\\\":\\\"Petrov2\\\"},{\\\"ID\\\":\\\"2\\\",\\\"FName\\\":\\\"Peta2\\\",\\\"LNmae\\\":\\\"Petrov2\\\"},{\\\"ID\\\":\\\"4\\\",\\\"FName\\\":\\\"Test\\\",\\\"LNmae\\\":\\\"Test\\\"}]\"}");
         }
         if (obj2.Type.equals("Person"))
         {
           mysrv.sendUser("{\"Type\":\"Get\",\"Data\":\"{\\\"Type\\\":\\\"Person\\\"}\",\"Add\":\"{\\\"ID\\\":\\\"1\\\",\\\"FName\\\":\\\"Peta2\\\",\\\"LName\\\":\\\"Petrov2\\\",\\\"bd\\\":\\\"11-12-1987\\\",\\\"uid\\\":\\\"2\\\",\\\"Phones\\\":[{\\\"ID\\\":\\\"1\\\",\\\"Type\\\":{\\\"Type\\\":\\\"Home\\\"},\\\"Number\\\":\\\"777-77-77\\\"},{\\\"ID\\\":\\\"3\\\",\\\"Type\\\":{\\\"Type\\\":\\\"Mob\\\"},\\\"Number\\\":\\\"777-77-77\\\"}],\\\"Addres\\\":[{\\\"Type\\\":{\\\"Type\\\":\\\"Work-a\\\"},\\\"ID\\\":\\\"1\\\",\\\"country\\\":{\\\"name\\\":\\\"Uk\\\"},\\\"city\\\":{\\\"name\\\":\\\"Dnepr\\\"},\\\"street\\\":{\\\"name\\\":\\\"Kirova\\\"},\\\"Add\\\":\\\"flat 30\\\"},{\\\"Type\\\":{\\\"Type\\\":\\\"Propiska\\\"},\\\"ID\\\":\\\"3\\\",\\\"country\\\":{\\\"name\\\":\\\"Uk\\\"},\\\"city\\\":{\\\"name\\\":\\\"Dnepr\\\"},\\\"street\\\":{\\\"name\\\":\\\"Kirova\\\"},\\\"Add\\\":\\\"flat 30\\\"}]}\"}");
         }
         if (obj2.Type.equals("PhoneT"))
         {
           mysrv.sendUser("{\"Type\":\"Get\",\"Data\":\"{\\\"Type\\\":\\\"PhoneT\\\"}\",\"Add\":\"[{\\\"ID\\\":\\\"1\\\",\\\"Type\\\":\\\"Home\\\"},{\\\"ID\\\":\\\"2\\\",\\\"Type\\\":\\\"Mob\\\"},{\\\"ID\\\":\\\"3\\\",\\\"Type\\\":\\\"TelT\\\"}]\"}");
         }
         if (obj2.Type.equals("AddrT"))
         {
           mysrv.sendUser("{\"Type\":\"Get\",\"Data\":\"{\\\"Type\\\":\\\"AddrT\\\"}\",\"Add\":\"[{\\\"Type\\\":\\\"Work-a\\\"},{\\\"Type\\\":\\\"Propiska\\\"},{\\\"Type\\\":\\\"AdrT\\\"}]\"}");
         }
         if (obj2.Type.equals("Country"))
         {
           mysrv.sendUser("{\"Type\":\"Get\",\"Data\":\"{\\\"Type\\\":\\\"Country\\\"}\",\"Add\":\"[{\\\"ID\\\":\\\"1\\\",\\\"name\\\":\\\"Uk\\\"},{\\\"ID\\\":\\\"2\\\",\\\"name\\\":\\\"Cz\\\"},{\\\"ID\\\":\\\"3\\\",\\\"name\\\":\\\"Countr\\\"}]\"}");
         }
         if (obj2.Type.equals("City"))
         {
           mysrv.sendUser("{\"Type\":\"Get\",\"Data\":\"{\\\"Type\\\":\\\"City\\\"}\",\"Add\":\"[{\\\"ID\\\":\\\"1\\\",\\\"name\\\":\\\"Dnepr\\\"},{\\\"ID\\\":\\\"3\\\",\\\"name\\\":\\\"Kiev\\\"},{\\\"ID\\\":\\\"4\\\",\\\"name\\\":\\\"City\\\"}]\"}");
         }
         if (obj2.Type.equals("Street"))
         {
           mysrv.sendUser("{\"Type\":\"Get\",\"Data\":\"{\\\"Type\\\":\\\"Street\\\"}\",\"Add\":\"[{\\\"ID\\\":\\\"1\\\",\\\"name\\\":\\\"Kirova\\\"},{\\\"ID\\\":\\\"3\\\",\\\"name\\\":\\\"Stre\\\"}]\"}");
         }
           
       
       }
       
       // SETER
       if (type.equals("Set"))
       {
         GType obj2 = gson.fromJson(data, GType.class);
         if (obj2.Type.equals("Person"))
         {
          FullPersone fp = gson.fromJson(add, FullPersone.class);
          
         }
         if (obj2.Type.equals("TypePhone"))
         {
           TypePhone fp = gson.fromJson(add, TypePhone.class);
           
         }
         if (obj2.Type.equals("TypeAdress"))
         {
           TypeAdress fp = gson.fromJson(add, TypeAdress.class);
           
         }
         if (obj2.Type.equals("Country"))
         {
           Country fp = gson.fromJson(add, Country.class);
           
         }
         if (obj2.Type.equals("City"))
         {
           City fp = gson.fromJson(add, City.class);
           
         }
         if (obj2.Type.equals("Street"))
         {
           Street fp = gson.fromJson(add, Street.class);
           
         }
       // log.debug(name);
       }
       
       //Del
       if (type.equals("Del"))
       {
         GType obj2 = gson.fromJson(data, GType.class);
         if (obj2.Type.equals("Person"))
         {
           FullPersone fp = gson.fromJson(add, FullPersone.class);
           
         }
         if (obj2.Type.equals("Phone"))
         {
           
         }
         if (obj2.Type.equals("Address"))
         {
           
         }
       }
       

    }

   
    
}
